from character import Character

class Coin(Character):
    # 构造函数
    def __init__(self, screen,x = 0, y = 0):
        super().__init__(screen)
        self.x = x
        self.y = y   
        self._destroyed = False   

    # 移动x,y
    def move(self, x, y):
        # 移动
        self.x += x
        self.y += y
        # 移动图片
        if hasattr(self,'rect') and self.rect:
            self.rect.x = self.x
            self.rect.y = self.y

        # 如果碰到屏幕底部边缘，则销毁
        if self.rect.bottom > self.screen.get_height():  # 检测是否与屏幕边缘发生碰撞
            self.destroy()